/**
 * Copyright (C) 2007 The AsyncMail Group <asyncmail@googlegroups.com>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *         http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.googlecode.asyncmail.smtpserver.mock;

import com.googlecode.asyncmail.smtp.SMTPResponse;
import com.googlecode.asyncmail.smtpserver.SMTPHandlerConfigurationData;
import com.googlecode.asyncmail.smtpserver.SMTPSession;
import com.googlecode.asyncmail.smtpserver.handler.LineHandler;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MockSMTPSession implements SMTPSession {

    private Map<String, Object> connState = new HashMap<String, Object>();

    private String user = null;

    private boolean relayingAllowed;

    private String remoteIP;

    private String remoteHost;

    private SMTPHandlerConfigurationData config;

    private Map<String, Object> state = new HashMap<String, Object>();

    private List<SMTPResponse> responses = new ArrayList<SMTPResponse>();

    public SMTPHandlerConfigurationData getConfigurationData() {
        return config;
    }

    public Map<String, Object> getConnectionState() {
        return connState;
    }

    public String getRemoteHost() {
        return remoteHost;
    }

    public String getRemoteIPAddress() {
        return remoteIP;
    }

    public String getSessionID() {
        return "Any-ID";
    }

    public Map<String, Object> getState() {
        return state;
    }

    public String getUser() {
        return user;
    }

    public boolean isRelayingAllowed() {
        return relayingAllowed;
    }

    public void resetState() {
        state.clear();
    }

    public void setRelayingAllowed(boolean relayingAllowed) {
        this.relayingAllowed = relayingAllowed;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public void setRemoteIPAddress(String remoteIP) {
        this.remoteIP = remoteIP;
    }

    public void setRemoteHost(String remoteHost) {
        this.remoteHost = remoteHost;
    }

    public void setConfigurationData(SMTPHandlerConfigurationData config) {
        this.config = config;
    }

    public void popLineHandler() {
        throw new UnsupportedOperationException("Unsupported method");
    }

    public void pushLineHandler(LineHandler overrideCommandHandler) {
        throw new UnsupportedOperationException("Unsupported method");
    }

    public void writeSMTPResponse(SMTPResponse response) {
        responses.add(response);
    }

    public List<SMTPResponse> getSTMPResponses() {
        return responses;
    }

}
